﻿var app = angular.module('Pokemon2App', ['ngRoute']);
app.config(function ($routeProvider) {
    $routeProvider.when('/', { templateUrl: '/Views/Home.html', controller: 'AddController' })
    .when('/Display', { templateUrl: '/Views/Table.html', controller: 'DisplayController' })
    .otherwise({templateUrl: '/Views/Error.html'})
});
app.factory('Pokemons', function () {
    return [];
})
app.controller('AddController', function ($scope, Pokemons, $location) {
    $scope.test = Pokemons;
    $scope.pushString = function (pokemon) {
        Pokemons.push({ name: pokemon.name, type: pokemon.type });
        pokemon = {};
        $location.path('/Display')
    }
   // $scope.test = "Add controller";
});
app.controller('DisplayController', function ($scope, Pokemons) {
    $scope.test = Pokemons;
    $scope.deletePokemon = function (pokemon) {
        var index = Pokemons.indexOf(pokemon);
        Pokemons.splice(index, 1);
    }
   // $scope.test = "Display controller";
});